// JavaScript Document
    var n=1;
	var count=4;

$(document).ready(function(e) {
	var url_a = getQueryString('a');
	if((url_a==null) || (url_a == 'init')){
		$("#home").attr('class','home_cli on');
	}
	else if(url_a == 'forumdetail' || url_a == 'search'){
		$("#forum").attr('class','forum_cli on');
	}
	else{
		$("#"+url_a).attr('class',url_a+'_cli on');
	}
	//初始化，执行定时效果
	t = setInterval("Autoshow()", 4000); 
	$("#banner_list a:not(:first-child)").hide();

	$("#ban li").click(function(){
			var i = $(this).attr('id');
			var lis = $(this).siblings();
			lis.find('img').attr('src',img_path+'images/off.png');
			$(this).find('img').attr('src',img_path+'images/on.png');
			cli(i-1);
			n = i;
		});
	//左右按键的效果		
	$("#cul-left").click(function(){
			up();
			//$("#ban li").eq(n).trigger('click');
		});
	$("#cul-right").click(function(){
			down();
			//$("#ban li").eq(q).trigger('click');
		});	
	//左右按键鼠标经过效果	
	$("#banner_list").hover(function(){clearInterval(t)}, function(){t = setInterval("Autoshow()", 4000);});
	$("#cul-left").hover(function(){clearInterval(t)}, function(){t = setInterval("Autoshow()", 4000);});
	$("#cul-right").hover(function(){clearInterval(t)}, function(){t = setInterval("Autoshow()", 4000);});
	//导航栏鼠标经过效果
	$("button").hover(function(){
		if($(this).hasClass('on')){
				return false;
			}
		var bu = $(this).attr('id');
		$(this).attr('class',bu+'_sel');
		},function (){
			if($(this).hasClass('on')){
				return false;
			}
			var bu = $(this).attr('id');
			$(this).attr('class',bu);
			}
		);
	//导航点击链接
	$(".main .header ul li button").click(function(){
		var id = $(this).attr('id');
		switch(id){
			case 'home':
				window.location.href = "index.php?m=content&c=index";
				break;
			case 'product':
				window.location.href = "index.php?m=content&c=index&a=product";
				break;
			case 'forum':
				window.location.href = "index.php?m=content&c=index&a=forum";
				break;
			case 'support':
				window.location.href = "index.php?m=content&c=index&a=support";
				break;
			case 'shop':
				window.location.href = "index.php?m=content&c=index";
				break;
			default:
				window.location.href = id;
				break;
		}
	});
	//微信二维码出现隐藏效果	
	$("#weixin").hover(function(){
		$("#code").css('visibility','visible');
		},function(){
			$("#code").css('visibility','hidden');
			}
			);
	//新浪微博点击效果
	$("#weibo").click(function(){
		window.open("http://weibo.com/u/2991975565?noscale_head=1#_0");
		});
	$("#gz").click(function(){
		window.open("http://weibo.com/u/2991975565?noscale_head=1#_0");
		});
	//表单验证
	$("#login").submit(function(){
		if($('#login input[name="username"]').val()==''){
			alert('请输入用户名~');
			$('input[name="username"]').focus();
			return false;
		}
		else if($('#login input[name="password"]').val()==''){
			alert('请输入密码~');
			$('input[name="password"]').focus();
			return false;
		}
	});
}); 


function cli(q){
	$("#banner_list a").fadeOut(500).parent().children().eq(q).fadeIn(500); 
	}
	
function Autoshow(){
		n = n >=(count) ? 0 : n++;
		$("#ban li").eq(n).trigger('click');
	}

function up(){
	n--;
	if(n--<=0){
		n=3;
		}
	$("#ban li").eq(n).trigger('click');
	}
	
function down(){
	n = n >=(count) ? 0 : n++;
	$("#ban li").eq(n).trigger('click');
	}

//js获取url参数
function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
	} 